{% extends 'base.html' %}
{% block title %}插件管理{% endblock %}
{% block subtitle %}插件列表{% endblock %}
{% block javascript %}
<script type="text/javascript" src="{{url_for('static',filename='js/jquery-1.11.0.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/jqueryui/js/jquery-ui-1.10.4.custom.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='js/bootstrap.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/datatables/js/jquery.dataTables.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/datatables/TableTools/js/TableTools.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/datatables/bootstrap/3/dataTables.bootstrap.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='js/datatables.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/customscroll/jquery.mCustomScrollbar.concat.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/jquery-easing/jquery.easing.1.3.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='lib/offlinejs/offline.min.js')}}"></script>
<script type="text/javascript" src="{{url_for('static',filename='js/script.js')}}"></script>

<script>
	function reverseStatus(id){
		$.get("/plugin/reverse/"+id);
	}

	$('#onclickSelect').change(function(){
		var id = $(this).find('option:selected').val();
		var status=$(this).find('option:selected').text();
		if(status == '前置'){
			$.get("/plugin/beforePlugin/"+id);
		}else if(status == '后置'){
			$.get("/plugin/afterPlugin/"+id);
		}else{
			return
		}
	})

</script>
<script type="text/javascript">
	$(function() {
		$('#showplugin').on('shown.bs.modal',
		function(e) {
			var btn = $(e.relatedTarget),
        	id = btn.data("id");
        	$.get("/plugin/pluginDetail/"+id, function(result){
				$("#plugindetail").html(result);
			  });
		})
	});
</script>
{% endblock %}
{% block css %}

<link rel="stylesheet" href="{{url_for('static',filename='css/bootstrap.min.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/offlinejs/themes/offline-theme-dark.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/bootstrap-override.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/font-awesome.min.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/layout.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/library.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/style.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/offlinejs/themes/offline-theme-dark.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/datatables/bootstrap/3/dataTables.bootstrap.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/datatables/TableTools/css/TableTools.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/jquery-fileupload/css/jquery.fileupload.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='lib/jquery-fileupload/css/jquery.fileupload-ui.css')}}">
<link rel="stylesheet" href="{{url_for('static',filename='css/poclist.css')}}">
{% endblock %}
{% block active5 %}class="active"{% endblock %}
{% block content %}
{% for msg in get_flashed_messages() %}
<div class="alert alert-success">
	<strong class="default">{{ msg }} </strong>
	<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
</div>

{% endfor %}

<div class="row">
			  <div class="col-md-12">
				  	<div class="panel panel-default">
					  <div class="panel-body">
						  <a href="{{url_for('plugin.refreshPlugin')}}"><button class="btn btn-success" ><i class="fa fa-anchor"></i> 刷新插件</button></a>
						  <a href="{{url_for('plugin.reverseAllStatus')}}"><button class="btn btn-info"><i class="fa fa-arrows-v"></i> 状态逆转</button></a>

						  <button type="button" class="btn btn-default" id="tooltip-right" data-toggle="tooltip" data-placement="right" title="" data-original-title="插件" style="border:none"><i class="fa fa-ellipsis-h"></i></button>

						  <div style="float:right; ">
							  <form  method="post" action="{{url_for('plugin.uploadPlugin')}}" enctype="multipart/form-data">
									<div>
										<span class="btn btn-success fileinput-button">
											<i class="fa fa-folder"></i>
											<span>选择文件</span>
											<input class="btn btn-success" type="file" name="files" multiple/>
										</span>
										<button type="submit" class="btn btn-primary start">
											<i class="fa fa-cloud-upload"></i>
											<span>提交</span>
										</button>
									</div>
								</form>
						  </div>
						  <br>
						  <br>
					  		<table cellpadding="0" cellspacing="0" border="0"
					  		class="table table-bordered">
									<thead>
									<tr>
										<th>id</th>
										<th>filename</th>
										<th>状态</th>
										<th>位置</th>
										<th>删除</th>
									</tr>
								</thead>
								<tbody>
									{% for plugin in plugins %}
									<tr >
										<td><input name="pocid" type="hidden" class="" value="{{plugin.id}}">{{plugin.id}}</td>
										<td><button class="btn" data-target="#showplugin" data-toggle="modal" data-id="{{plugin.id}}">{{plugin.filename}}</button></td>
										<td>
											<div class="switch-box">
												<input id="{{plugin.id}}" type="checkbox" class="switch" onclick="reverseStatus({{plugin.id}})" {% if plugin.status %}checked{% endif %}/>
												<label for="{{plugin.id}}"></label>
											</div>
										</td>
										<td>

											<select id="onclickSelect">
											   <option value="{{plugin.id}}" {% if not plugin.position %}selected="selected"{% endif %}>前置</option>
											   <option value="{{plugin.id}}" {% if plugin.position %}selected="selected"{% endif %}>后置</option>
											</select>
										</td>
										<td><a href="{{url_for('plugin.delPlugin',id=plugin.id)}}"><i class="fa fa-times"></i></a></td>
									</tr>
								{% endfor %}
								</tbody>
								</table>
						  <div class="modal fade" id="showplugin" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
							<div class="modal-dialog">
								<div class="panel panel-default">
										  <div class="panel-heading">
											<h3 class="panel-title">插件详情</h3>
														<div class="panel-options pull-right">
														  </div>
										  </div>
										  <div class="panel-body">
<!--											  <div class="panel-body" id="pocdetail" style="height: 150px;overflow: auto;">-->
<!--												  <pre></pre>-->
			<!--								   <p class="list-group-item-text"></p>-->
<!--											  </div>-->
											<div  style="white-space: pre;"><pre id="plugindetail" style="max-height:500px"></pre></div>
										  </div>
								</div>
							</div>
						</div>
						  <div style="text-align:center">
								{% import 'pages.html' as pg %}
								{{ pg.my_paginate(pagination,'plugin.pluginlist') }}
							</div>
					  </div>
				  	</div>

			  </div>
            </div>

{% endblock %}
